<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>mtext</title>
</head>
<script src="libs/createjs-2015.11.26.min.js"></script>
<script src="js/MText.js"></script>
<script>
	var canvas, stage, exportRoot;
	function init() {
		canvas = document.getElementById("canvas");
		handleComplete();
	}
	function handleComplete() {

		//This function is always called, irrespective of the content. You can use the variable "stage" after it is created in token create_stage.
        console.log("sssssssss");
		var text = new createjs.MText("始还没发现这个问题，只是在想为什么设了要textWidth You can，use，the variable 却无法换行。去官方找例子，都是好的，到我这里就不行了 You can ", "20px Arial", "#ff7700");
		text.x = 10;
		text.lineWidth=80;
		console.log("lineWidth2",text.lineWidth,text.getMeasuredWidth(),text.getMeas);
		stage = new createjs.Stage(canvas);
		stage.addChild(text);
		//Registers the "tick" event listener.
		createjs.Ticker.setFPS(30);
		createjs.Ticker.addEventListener("tick", stage);
		//Code to support hidpi screens and responsive scaling.
		(function(isResp, respDim, isScale, scaleType) {
			var lastW, lastH, lastS=1;
			//window.addEventListener('resize', resizeCanvas);
			resizeCanvas();
			function resizeCanvas() {
				var w = 550, h = 400;
				var iw = window.innerWidth, ih=window.innerHeight;
				var pRatio = window.devicePixelRatio, xRatio=iw/w, yRatio=ih/h, sRatio=1;
				if(isResp) {
					if((respDim=='width'&&lastW==iw) || (respDim=='height'&&lastH==ih)) {
						sRatio = lastS;
					}
					else if(!isScale) {
						if(iw<w || ih<h)
							sRatio = Math.min(xRatio, yRatio);
					}
					else if(scaleType==1) {
						sRatio = Math.min(xRatio, yRatio);
					}
					else if(scaleType==2) {
						sRatio = Math.max(xRatio, yRatio);
					}
				}
				canvas.width = w*pRatio*sRatio;
				canvas.height = h*pRatio*sRatio;
				canvas.style.width = w*sRatio+'px';
				canvas.style.height = h*sRatio+'px';
				stage.scaleX = pRatio*sRatio;
				stage.scaleY = pRatio*sRatio;
				lastW = iw; lastH = ih; lastS = sRatio;
			}
		})(false,'both',false,1);
	}
</script>
<!-- write your code here -->
</head>
<body onload="init();" style="margin:0px;">
<canvas id="canvas" width="550" height="400" style="display: block; background-color:rgb(255,254,250)"></canvas>
</body>
</html>
